package cn.tedu.zhxy.service.impl;

import cn.tedu.zhxy.entity.Clazz;
import cn.tedu.zhxy.mapper.ClazzMapper;
import cn.tedu.zhxy.service.ClazzService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-07-20
 */
@Service
public class ClazzServiceImpl extends ServiceImpl<ClazzMapper, Clazz> implements ClazzService {

    @Override
    public IPage<Clazz> selectClazz(Page<Clazz> pageParam, Clazz clazz) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (!StringUtils.isEmpty(clazz.getGradeName())){
            queryWrapper.eq("grade_name", clazz.getGradeName());
       }
       if(!StringUtils.isEmpty(clazz.getName())){
          queryWrapper.eq("name",clazz.getName());
       }
       return  baseMapper.selectPage(pageParam,queryWrapper);

    }
}
